#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;
const int N = 3 * 1e6 + 10;

vector<int> prime; // 存储质数
// bool is_prime[N];  // 判断是否是质数
vector<bool> is_prime(N, true);

void era(int n)
{
  for (int i = 2; i <= n; i++)
  {
    if (is_prime[i])
      prime.push_back(i);
    for (int j = i + i; j <= n; j++)
      is_prime[j] = false;
  }
}
int seek(int i)
{
  for (int v : prime)
  {
    if (i % v == 0)
      return v;
  }
  return -1;
}
int main()
{
  ios::sync_with_stdio(0), cin.tie(0);
  int t, n, sum;
  era(N - 10);
  cin >> t;
  while (t--)
  {
    sum = 0;
    cin >> n;
    for (int i = 2; i <= n; i++)
      sum += seek(i);
    cout << sum << '\n';
  }
  return 0;
}
